package gupao.concurrency.simpledemo.simulate;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class BizContext {

    private static final InheritableThreadLocal<String> UID_THREAD_LOCAL = new InheritableThreadLocal<>();

    public static String getUidFromContext(){
        String uid = UID_THREAD_LOCAL.get();
        log.info("{} get uid context: {}", Thread.currentThread().getName(), uid);
        return uid;
    }

    public static void clean(){
        UID_THREAD_LOCAL.remove();
    }

    public static void setUid(String uid){
        log.info("{} set context: uid = {}", Thread.currentThread().getName(), uid);
        UID_THREAD_LOCAL.set(uid);
    }
}
